<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="add">添加</button>
        <button v-on:click="del">减少</button>
        <table border="3" width="50%" style="border-collapse: collapse;">
            <tr>
                <th>宇宙维度</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
            </tr>
            <tr align="center" v-for="rick in universes">
                <td>{{rick.universe}}</td>
                <td>{{rick.name}}</td>
                <td>{{rick.gender}}</td>
                <td>{{rick.age}}</td>
            </tr>
        </table>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                universes : [
                    {universe:"C-137",name:"Rick",gender:"male",age:"111"},
                    {universe:"unknow",name:"Rick",gender:"female",age:"19"}
                ]
            },
            methods: {
                add(){
                    var rick = {universe:"C-137",name:"Rick",gender:"male",age:"111"};
                    this.universes.push(rick);
                },
                del(){
                    this.universes.pop();
                }
            }
        })
    </script>
</body>
</html>